
define(function(){
        return {
            callNativePlugin:function (opType, jsonString, callback) {
                var type = opType;
                function callJavaFunction(){
                    alert("callJava")
                    if(type == "stop"){
                        return cordova.exec(null, failureCallback,  'BdLocation', type, []);
                    }
                    else{
                        return cordova.exec(successCallback, failureCallback,  'BdLocation', type, []);
                    }
                }

                function successCallback(result) {
                    if(type == "location"){
                        callback(result);
                        type = "stop";
                        callJavaFunction();
                    }
                }

                function failureCallback(result) {
                    callJavaFunction();
                }

                callJavaFunction();
            }
        }
    }
)
